*******************
*This code replicates the analysis presented in the following article and related appendixes:

*Article: What Influences Citizen Forecasts? The Effects of Information, Elite Cues, and Social Cues
*Journal: Political Behavior
*Authors: Davide Morisi and Thomas Leeper
*Date: June 27, 2022

******************

*EXPERIMENT ANALYSIS AND APPENDIX C (YOUGOV DATA)

cd "C:\Users\Davide Morisi\Dropbox\research_inprogress\Citizen_forecasts"

use "Replication\data\yougov_recoded.dta", clear

*exclude those who are not assigned to treatment groups (non-partisans)
drop if treatment==.

*covariates
gen age10 = Age/10
gen day_int2 = day_int+1
global demo "i.female age10 ib2.ethnicity i.income6"
*additional variables
fre att_high vote3 day_int2 party4_des treatment_all


*
*Table C1. Treatment effects on Leave forecasts
eststo clear
eststo: reg forecast100 i.treatment
eststo: reg forecast100 i.treatment $demo i.education2 day_int
eststo: reg forecast100 i.treatment $demo i.education2 day_int attention i.brexit_vote
*adding party ID
eststo: reg forecast100 i.treatment i.partyid4
eststo: reg forecast100 i.treatment i.partyid4 $demo i.education2 day_int attention i.brexit_vote
esttab using "~TableC1.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C1. Average treatment effects") compress noeqlines replace 

*Effects on standardized dv
egen st_forecast100 = std(forecast100)
eststo clear
eststo: reg st_forecast100 i.treatment
eststo: reg st_forecast100 i.treatment $demo i.education2 day_int
eststo: reg st_forecast100 i.treatment $demo i.education2 day_int attention i.brexit_vote
*adding party ID
eststo: reg st_forecast100 i.treatment i.partyid4
eststo: reg st_forecast100 i.treatment i.partyid4 $demo i.education2 day_int attention i.brexit_vote
esttab using "~TableC1st.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C1. Average treatment effects") compress noeqlines replace 


************
*Figure 4: Treatment effects on Leave forecasts relative to control
*model 1 in table C1
fre treatment
recode treatment (1=1 "Control") (3=2 "Social cue") (5=3 "Social + Remain") (7=4 "Social + Leave") ///
(2=5 "Elite cue") (4=6 "Elite + Remain") (6=7 "Elite + Leave"), gen(treat_figure)
reg forecast100 i.treat_figure
margins, dydx(treat_figure) post
coefplot, xline(0, lpattern(dash) lcolor(gs10)) xtitle("Effect on forecast share of Leave votes") ///
graphregion(color(white)) level(90 95)


*
*Table C2. Effects of information treatments on Leave forecasts
eststo clear
*elite cue as ref cat
eststo: reg forecast100 ib2.treatment
eststo: reg forecast100 ib2.treatment $demo i.education2 day_int attention i.brexit_vote
eststo: reg forecast100 ib2.treatment $demo i.partyid4 i.education2 day_int attention i.brexit_vote
*social cue as ref cat
eststo: reg forecast100 ib3.treatment
eststo: reg forecast100 ib3.treatment $demo i.education2 day_int attention i.brexit_vote
eststo: reg forecast100 ib3.treatment i.partyid4 $demo i.education2 day_int attention i.brexit_vote
esttab using "~TableC2.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C2. Effects of info") compress noeqlines replace 


*
*Table C3. Interactions with edu and attention
fre edu_high
*panel A
eststo clear
eststo: reg forecast100 i.treatment##i.edu_high
eststo: reg forecast100 i.treatment##i.edu_high $demo day_int i.att_high i.brexit_vote
esttab using "~TableC3.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C3. Interactions with edu and attention") wide compress noeqlines replace 
*Panel B. share of Leave forecasts by education level (same models in panel A)
*low edu
eststo clear
reg forecast100 i.treatment##i.edu_high
eststo no_control: margins treatment, at(edu_high==0) post
reg forecast100 i.treatment##i.edu_high $demo day_int i.att_high i.brexit_vote
eststo controls: margins treatment, at(edu_high==0) post
esttab no_control controls using "~TableC3_B1.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C3") wide compress noeqlines replace 
*high edu
eststo clear
reg forecast100 i.treatment##i.edu_high
eststo no_control: margins treatment, at(edu_high==1) post
reg forecast100 i.treatment##i.edu_high $demo day_int i.att_high i.brexit_vote
eststo controls: margins treatment, at(edu_high==1) post
esttab no_control controls using "~TableC3_B2.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C3") wide compress noeqlines replace 


****
*Figure 5: Treatment effects on Leave forecasts by education levels
fre edu_high
*low edu
reg forecast100 i.treat_figure##i.edu_high
margins, dydx(treat_figure) at(edu_high==0) post
coefplot, xline(0, lpattern(dash) lcolor(gs10)) xtitle("Effect at low education") ///
graphregion(color(white)) level(90 95) name(low_edu, replace)
*high edu
reg forecast100 i.treat_figure##i.edu_high
margins, dydx(treat_figure) at(edu_high==1) post
coefplot, xline(0, lpattern(dash) lcolor(gs10)) xtitle("Effect at high education") ///
graphregion(color(white)) level(90 95) name(high_edu, replace)
*combine
graph combine low_edu high_edu, graphregion(color(white))



*
*Table C4. Interactions with attention to politics
fre att_high
eststo clear
eststo: reg forecast100 i.treatment##i.att_high
eststo: reg forecast100 i.treatment##i.att_high $demo day_int i.edu_high i.brexit_vote
esttab using "~TableC4.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C4. Interactions with attention") compress noeqlines replace 


***
*Figure C1. Treatment effects on Leave forecasts by level of attention to politics
fre att_high
*low edu
reg forecast100 i.treat_figure##i.att_high
margins, dydx(treat_figure) at(att_high==0) post
coefplot, xline(0, lpattern(dash) lcolor(gs10)) xtitle("Effect at low attention") ///
graphregion(color(white)) level(90 95) name(low_att, replace)
*high edu
reg forecast100 i.treat_figure##i.att_high
margins, dydx(treat_figure) at(att_high==1) post
coefplot, xline(0, lpattern(dash) lcolor(gs10)) xtitle("Effect at high attention") ///
graphregion(color(white)) level(90 95) name(high_att, replace)
*combine
graph combine low_att high_att, graphregion(color(white))


*
*Table C5. Interactions with Party ID
fre partyid4
eststo clear
eststo: reg forecast100 i.treatment##i.partyid4
eststo: reg forecast100 i.treatment##i.partyid4 $demo i.edu_high day_int i.att_high
esttab using "~TableC5.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C5. Interactions with party ID") wide compress noeqlines replace 
*panel b. marginal effects
eststo clear
reg forecast100 i.treatment##i.partyid4
eststo: margins partyid4, dydx(2.treatment 3.treatment) post
reg forecast100 i.treatment##i.partyid4 $demo i.edu_high day_int i.att_high
eststo: margins partyid4, dydx(2.treatment 3.treatment) post
esttab using "~TableC5mar.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C5. Interactions with party ID") wide compress noeqlines replace 


*******
*Figure C2. Treatment effects on Leave forecasts by party identification
*elite cues
reg forecast100 i.treatment##i.partyid4
margins partyid4, dydx(2.treatment) post
coefplot, xline(0, lcolor(gs10) lpattern(dash)) ///
title("Effect of elite cues by party ID") ///
xtitle("Effect on Leave forecasts") level(90 95) ///
graphregion(color(white)) name(elite1, replace)
*do social cues have heterogeneous effects depending on party id? 
reg forecast100 i.treatment##i.partyid4
margins partyid4, dydx(3.treatment) post
coefplot, xline(0, lcolor(gs10) lpattern(dash)) ///
title("Effect of social cues by party ID") ///
xtitle("Effect on Leave forecasts") level(90 95) ///
graphregion(color(white)) name(social1, replace)
*combine
graph combine elite1 social1, graphregion(color(white))


*
*Table C6. Manipulation checks: treatment effects on forecasting Leave votes among in-party vot-ers/politicians
*What about <PARTY> politicians? What percent of <PARTY> voters do you anticipate will vote for Britain to leave the European Union? (Please enter a number between 0 and 100.)
fre Q6
*What about <PARTY> voters? What percent of <PARTY> voters do you anticipate will vote for Britain to leave the European Union? (Please enter a number between 0 and 100.)
fre Q5
eststo clear
*In-party politicians
eststo: reg Q6 i.treatment
eststo: reg Q6 i.treatment $demo i.education2 day_int
eststo: reg Q6 i.treatment $demo i.education2 day_int attention i.brexit_vote
*in-party voters
eststo: reg Q5 i.treatment
eststo: reg Q5 i.treatment $demo i.education2 day_int
eststo: reg Q5 i.treatment $demo i.education2 day_int attention i.brexit_vote
esttab using "~TableC6.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C6") compress noeqlines replace 


*
*Table C7. Effects of information treatments on EU attitudes
fre attitude_postrev
eststo clear
*elite cue as ref cat
eststo: reg attitude_postrev ib2.treatment
eststo: reg attitude_postrev ib2.treatment $demo i.education2 day_int attention i.brexit_vote
*social cue as ref cat
eststo: reg attitude_postrev ib3.treatment
eststo: reg attitude_postrev ib3.treatment $demo i.education2 day_int attention i.brexit_vote
esttab using "~TableC7.rtf", ///
b(%6.3f) se(%6.3f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C7. Effects of info on EU attitudes") compress noeqlines replace 


*
*Table C8. Mediation analysis
gen forecast01 = forecast100/100
sum forecast01 // 0=100% remain, 1=100% leave
recode treatment (2 3=1 "cue") (4/7=0 "arguments") (1=.), gen(control_cue)
recode treatment (4 5=1 "remain") (2 3 6 7=0) (1=.), gen(remain_arg)
recode treatment (6 7=1 "leave") (2/5=0) (1=.), gen(leave_arg)
recode treatment (2 4 6=1 "elite cues") (3 5 7=0 "social cues") (1=.), gen(cov_elite)

sem (attitude_postrev <- remain_arg cov_elite) (attitude_postrev <- leave_arg cov_elite) ///
(forecast01 <- attitude_postrev remain_arg leave_arg cov_elite)
estat teffects


*
*Table C9. Treatment effects on forecast accuracy 
sum accuracy_sq 
eststo clear
eststo: reg accuracy_sq i.treatment
eststo: reg accuracy_sq i.treatment i.edu_high  $demo day_int attention i.brexit_vote
eststo: reg accuracy_sq i.treatment##i.edu_high
eststo: reg accuracy_sq i.treatment##i.edu_high  $demo day_int attention i.brexit_vote
esttab using "~TableC9.rtf", ///
b(%6.2f) se(%6.2f) starlevels(* .1 ** .05 *** .01) scalars (r2_a r2_p) title("Table C9.") wide compress noeqlines replace 


***
*Figure C3 based on table C9
fre edu_high
eststo clear
*all
reg accuracy_sq i.treatment
margins, dydx(treatment) post
coefplot, xline(0, lcolor(gs10) lpattern(dash)) ///
title("All respondents") ///
xtitle("") level(90 95) ///
graphregion(color(white)) name(all, replace)
*low edu
reg accuracy_sq i.treatment##i.edu_high
margins, dydx(treatment) at(edu_high==0) post
coefplot, xline(0, lcolor(gs10) lpattern(dash)) ///
title("Low education") ///
xtitle("") level(90 95) ///
graphregion(color(white)) name(low_edu, replace)
*high edu
reg accuracy_sq i.treatment##i.edu_high
margins, dydx(treatment) at(edu_high==1) post
coefplot, xline(0, lcolor(gs10) lpattern(dash)) ///
title("High education") ///
xtitle("") level(90 95) ///
graphregion(color(white)) name(high_edu, replace)
*combined
graph combine all low_edu high_edu, graphregion(color(white)) 





